using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Fall_State : Ab_State
{
    // Start is called before the first frame update
    private void OnEnable()
    {
        if (isStarted == false) return;
        body.velocity = new Vector3(0, body.velocity.y);
    }

    protected override void Start()
    {
        base.Start();
        InputActions.Player.Jump.started += (context) =>
        {
            if (!this.gameObject.activeSelf) return;
            if (player.canJump)
                animator.SetTrigger("Jump");
        };
    }

    private void FixedUpdate()
    {
        if (player.isMoving)
            body.velocity = new Vector3(player.transform.right.x * player.SpeedInSky, body.velocity.y);
        else
            body.velocity = new Vector3(0, body.velocity.y);

        if (player.isOnGroud && body.velocity.y * player.transform.up.y <= 0)
            animator.SetTrigger("Land");
    }
}
